Exploring trends and variation in biologic therapies for severe asthma

true , true , true , true
2021-12-01

Background

See this paper (Goldacre and MacKenna 2020).

Methods

Medicines codelist

Show code
# Define vector with selected SNOMED codes for XXX
snomed_asthma_mabs_list <- c("18671311000001102",
                             "18671411000001109",
                             "37564311000001105",
                             "37564411000001103",
                             "31210311000001108",
                             "33999611000001101",
                             "34812511000001102",
                             "37854611000001108",
                             "35298511000001102")

Data

NHS Trusts

Show code
# Load ETR data
df_etr <- readr::read_csv(here::here("data/etr_tidy.csv")) 
Show code
# Sustainability and Transformation Partnerships (STPs) 
df_etr %>% 
  select(ods_code, ods_name, region_code, stp_code, address_line_4, postcode) %>%
  reactable::reactable(filterable = TRUE,
                       columns = list(ods_code = reactable::colDef(name = "Code", 
                                                                   minWidth = 50),
                                      ods_name = reactable::colDef(name = "Name", 
                                                                   minWidth = 200),
                                      region_code = reactable::colDef(name = "Region", 
                                                                   minWidth = 50),
                                      stp_code = reactable::colDef(name = "STP", 
                                                                   minWidth = 50),
                                      address_line_4 = reactable::colDef(name = "City", 
                                                                   minWidth = 100),
                                      postcode = reactable::colDef(name = "Postcode", 
                                                                   minWidth = 50)
                                      ),
                       style = list(fontSize = "12px"),
                       highlight = TRUE)

Secondary Care Medicines Data (SCMD)

Connect to database, filter, and collect data.

Show code
# Get SCMD dataset
db_scmd <- dplyr::tbl(conn_ebm_scmd, sql_query_scmd)

# Create dataframe for table
db_scmd_asthma <- db_scmd %>% 
  dplyr::filter(vmp_snomed_code %in% snomed_asthma_mabs_list) %>% 
  dplyr::arrange(ods_code, year_month, dplyr::desc(total_quantity))

df_scmd_asthma <- dplyr::collect(db_scmd_asthma)

df_scmd_asthma_names <- df_scmd_asthma %>% 
  dplyr::left_join(dplyr::select(df_etr, ods_code, ods_name), by = "ods_code") %>% 
  dplyr::mutate(ods_name = dplyr::case_when(is.na(ods_name) ~ ods_code,
                                            TRUE ~ ods_name))

The following table shows the full raw data used in this notebook.

Show code
# Create table
df_scmd_asthma_names %>% 
  dplyr::select(ods_name, year_month, vmp_snomed_code, vmp_product_name, total_quantity) %>%
  reactable::reactable(filterable = TRUE,
                       defaultSorted = list("total_quantity" = "desc", "year_month" = "desc"),
                       groupBy = c("ods_name"),
                       columns = list(total_quantity = reactable::colDef(name = "Count",
                                                                         minWidth = 50,
                                                                         aggregate = "sum",
                                                                         format = reactable::colFormat(digits = 0)),
                                      ods_name = reactable::colDef(name = "Trust", 
                                                                   minWidth = 200),
                                      vmp_product_name = reactable::colDef(name = "Product", 
                                                                           minWidth = 200,
                                                                           cell = function(value, index) {
                                                                             vmp_snomed_code <- paste0("SNOMED Code: ", df_scmd_asthma_names$vmp_snomed_code[index])
                                                                             vmp_snomed_code <- if (!is.na(vmp_snomed_code)) vmp_snomed_code else "Unknown"
                                                                             div(
                                                                               div(style = list(fontWeight = 600), value),
                                                                               div(style = list(fontSize = 12), vmp_snomed_code))
                                                                             }
                                                                           ),
                                      year_month = reactable::colDef(name = "Month", 
                                                                     minWidth = 50),
                                      vmp_snomed_code = reactable::colDef(show = FALSE)
                                      
                                      ),
                       style = list(fontSize = "12px"),
                       highlight = TRUE)

Dictionary of Medicines and Devices (dm+d)

Connect to database, filter, and collect data.

Show code
db_dmd_info <- dplyr::tbl(conn_ebm_scmd, sql_query_dmd_info)

df_dmd_info <- db_dmd_info %>% 
  filter(vmp_snomed_code %in% snomed_asthma_mabs_list) %>% 
  collect()

Table with raw data.

Show code
df_dmd_info %>% 
  select(vmp_snomed_code, bnf_code, vtmnm, form_descr, form_cd, 
         udfs, udfs_descr,
         strnt_nmrtr_val, strnt_nmrtr_uom) %>%
  reactable::reactable(filterable = TRUE,
                       columns = list(vmp_snomed_code = reactable::colDef(name = "SNOMED Code", 
                                                                           minWidth = 200,
                                                                           cell = function(value, index) {
                                                                             bnf_code <- paste0("BNF: ", df_dmd_info$bnf_code[index])
                                                                             bnf_code <- if (!is.na(bnf_code)) bnf_code else "Unknown"
                                                                             div(
                                                                               div(style = list(fontWeight = 600), value),
                                                                               div(style = list(fontSize = 12), bnf_code))
                                                                             }
                                                                           ),
                                      bnf_code = reactable::colDef(show = FALSE)),
                       style = list(fontSize = "12px"),
                       highlight = TRUE)

Convert volume

Show code
df_scmd_asthma_ddd <- df_scmd_asthma %>% 
  left_join(df_dmd_info, by = c("vmp_snomed_code", "vmp_product_name")) %>% 
  mutate(volume_singles = total_quantity / udfs,
         volume_mg_strength = volume_singles * ifelse(is.na(strnt_dnmtr_val), strnt_nmrtr_val, strnt_nmrtr_val * (udfs / strnt_dnmtr_val)),
         mg_per_ddd = case_when(
           vtmnm == "Omalizumab" ~ 16,
           vtmnm == "Mepolizumab" ~ 3.6,
           vtmnm == "Reslizumab" ~ 7.1,
           vtmnm == "Benralizumab" ~ 0.54,
           TRUE ~ NA_real_), 
         volume_ddd = volume_mg_strength / mg_per_ddd)

Results

Show code
temp_ggplot <- df_scmd_asthma_ddd %>%
  group_by(year_month, vtmnm) %>%
  summarise(volume_ddd = sum(volume_ddd)) %>% 
  ggplot(aes(x = year_month, y = volume_ddd, colour = vtmnm, group = vtmnm)) +
  geom_line(size = 1, alpha = 0.5) +
  geom_point(aes(text = paste0("<b>Date:</b> ", year_month, "<br>",
                               "<b>Volume:</b> ", round(volume_ddd, 0), "<br>",
                               "<b>Medication:</b> ", vtmnm)), size = 2) +
  scale_x_date() +
  scale_colour_viridis_d(end = .9) +
  labs(title = "National prescribing of asthma biologics",
       x = NULL, y = "Defined Daily Dose",
       colour = NULL)

plotly::ggplotly(temp_ggplot,
                 tooltip = "text") %>%
  plotly::config(displayModeBar = FALSE)
Goldacre, Ben, and Brian MacKenna. 2020. “The NHS Deserves Better Use of Hospital Medicines Data.” BMJ 370 (July): m2607. https://doi.org/10.1136/bmj.m2607.

References

Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.